package be.tf.freemaind.servlet;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import be.tf.freemaind.service.TreeGenerator;

import com.mysql.jdbc.Statement;

/**
 * Servlet implementation class IndexServlet
 */
public class IndexServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		//request.getContextPath()+
//		PrintWriter pw= new PrintWriter(new FileWriter(new File("map.mm")));
//		TreeGenerator treeGenerator=new TreeGenerator();
//		Statement stm= (Statement) this.getServletContext().getAttribute("stm");
//		String map=treeGenerator.xmlMap(stm);
//		pw.print(map);
//		pw.flush();
//		pw.close();
//		
		RequestDispatcher dispatcher = getServletContext()
				.getRequestDispatcher("/MaindMap.jsp");
		dispatcher.forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
